package editor.windows;

import adventure.AdventureEdit;
import adventure.placeable.ItemEdit;
import adventure.placeable.ItemUnlocks;
import adventure.placeable.PlaceableManager;
import adventure.placeable.PlaceableManagerEdit;
import java.text.NumberFormat;
import java.util.ArrayList;

/**
 *
 * @author Michael Hanns
 *
 */
public class DialogAddItemView extends javax.swing.JDialog {

    private static final long serialVersionUID = -870611444834967650L;
    private AdventureEdit adv;
    private PlaceableManager placeables;
    private int totalItems;
    int destX;
    int destY;
    int destZ;
    private WITNAFrameView parent;

    /**
     * Creates new form EditorItemView
     */
    public DialogAddItemView(java.awt.Frame parent, AdventureEdit a,
            int x, int y, int z) {
        super(parent, true);
        this.parent = (WITNAFrameView) parent;
        destX = x;
        destY = y;
        destZ = z;
        adv = a;
        placeables = (PlaceableManager) adv.getPlaceableManager();
        initComponents();
        if (placeables.getItem(1).getID() == 0) {
            ((PlaceableManagerEdit) placeables).newItem();
        }
        fillTable();
        getItemData(totalItems - 1);
    }

  
    public void fillTable() {
        itemListTable.removeAll();

        int x = 1;
        while (placeables.getItem(x).getID() != 0) {
            itemListTable.getModel().setValueAt(placeables.getItem(x).getID(), x - 1, 0);
            itemListTable.getModel().setValueAt(placeables.getItem(x).getName(), x - 1, 1);
            x++;
        }

        totalItems = x;

        itemListTable.changeSelection(x - 1, 2, false, false);
    }

    public void getItemData(int row) {
        if (row > 0) {
            unlocksCombo.removeAllItems();

            ItemEdit item = (ItemEdit) placeables.getItem(row);

            idBox.setText("" + item.getID());
            nameBox.setText(item.getName());
            descriptionBox.setText(item.getDescription());
            typeBox.setSelectedItem(item.getItemType());
            typeModBox.setText("" + item.getModifier());
            currencyValueBox.setText("" + item.getCurrencyValue());

            if (!item.isConsumable()) {
                consumableBox.setSelected(false);
                totalUsesBox.setText("");
            } else {
                consumableBox.setSelected(true);
                totalUsesBox.setText("" + item.getTotalUses());
            }

            if (!item.isTemporary()) {
                temporaryBox.setSelected(false);
                ticksRemainBox.setEnabled(false);
                ticksRemainBox.setText("");
            } else {
                temporaryBox.setSelected(true);
                ticksRemainBox.setEnabled(true);
                ticksRemainBox.setText("" + item.getTicksRemaining());
            }

            visibleBox.setSelected(item.isVisible());

            boundBox.setSelected(item.isBound());

            lightSourceBox.setSelected(item.isLightSource());

            ArrayList<ItemUnlocks> unlocks = item.getUnlocks();
            for (int x = 0; x < unlocks.size(); x++) {
                unlocksCombo.addItem(unlocks.get(x).getStringRepresentation());
            }

        }
    }

    private void addItem() {
        int id = Integer.parseInt(idBox.getText());
        String name = nameBox.getText();

        if (id > 0 && name.length() > 0) {

            adv.getRoomManager().addItemToRoom(placeables.getItem(id), destX, destY, destZ);
            parent.getRoomDetails(destX, destY, destZ);
            parent.printToConsole("Item " + name + " added to room "
                    + "(" + destX + "," + destY + "," + destZ + ").");
            parent.setUnsavedChanges(true);
        } else {
            parent.printToConsole("You must specify a name for the trigger before adding to a room!");
        }
        dispose();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        itemListPane = new javax.swing.JScrollPane();
        itemListTable = new javax.swing.JTable();
        nameBox = new javax.swing.JFormattedTextField();
        idBox = new javax.swing.JFormattedTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        descriptionBox = new javax.swing.JTextPane();
        idLabel = new javax.swing.JLabel();
        nameLabel = new javax.swing.JLabel();
        descriptionLabel = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        closeButton = new javax.swing.JButton();
        addButton = new javax.swing.JButton();
        temporaryBox = new javax.swing.JCheckBox();
        currencyValueLabel = new javax.swing.JLabel();
        ticksRemainBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());
        ticksRemainLabel = new javax.swing.JLabel();
        lightSourceBox = new javax.swing.JCheckBox();
        visibleBox = new javax.swing.JCheckBox();
        typeModBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());
        typeBox = new javax.swing.JComboBox();
        consumableBox = new javax.swing.JCheckBox();
        currencyValueBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());
        boundBox = new javax.swing.JCheckBox();
        typeModLabel = new javax.swing.JLabel();
        totalUsesBox = new javax.swing.JFormattedTextField(NumberFormat.getInstance());
        totalUsesLabel = new javax.swing.JLabel();
        typeLabel = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        unlocksCombo = new javax.swing.JComboBox();

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane2.setViewportView(jList1);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Add Item");
        setAlwaysOnTop(true);
        setLocationByPlatform(true);
        setResizable(false);

        itemListTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "#", "Name"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        itemListTable.setToolTipText("Item list");
        itemListTable.setColumnSelectionAllowed(true);
        itemListTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        itemListTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                itemListTableMouseClicked(evt);
            }
        });
        itemListPane.setViewportView(itemListTable);
        itemListTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        itemListTable.getColumnModel().getColumn(0).setMinWidth(10);
        itemListTable.getColumnModel().getColumn(0).setPreferredWidth(25);
        itemListTable.getColumnModel().getColumn(0).setMaxWidth(25);

        nameBox.setEditable(false);
        nameBox.setToolTipText("Item name");
        nameBox.setEnabled(false);

        idBox.setEditable(false);
        idBox.setToolTipText("Item number");
        idBox.setEnabled(false);

        descriptionBox.setEditable(false);
        descriptionBox.setToolTipText("Item description");
        descriptionBox.setEnabled(false);
        jScrollPane1.setViewportView(descriptionBox);

        idLabel.setText("ID:");

        nameLabel.setText("Name:");

        descriptionLabel.setText("Description:");

        closeButton.setText("Close");
        closeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeButtonActionPerformed(evt);
            }
        });

        addButton.setText("Add to (" + destX + "," + destY + "," + destZ+")");
        addButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addButtonActionPerformed(evt);
            }
        });

        temporaryBox.setText("Temporary");
        temporaryBox.setToolTipText("Item consumable (y/n)");
        temporaryBox.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                temporaryBoxStateChanged(evt);
            }
        });
        temporaryBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                temporaryBoxActionPerformed(evt);
            }
        });

        currencyValueLabel.setText("Currency Value:");

        ticksRemainBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));
        ticksRemainBox.setEnabled(false);

        ticksRemainLabel.setText("Ticks Remain:");

        lightSourceBox.setText("Light Source");

        visibleBox.setText("Visible");
        visibleBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visibleBoxActionPerformed(evt);
            }
        });

        typeModBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));

        typeBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "MISC", "WEAPON", "OFFHAND", "HEAD", "CHEST", "FEET", "HPOTION", "SPOTION", "FOOD" }));
        typeBox.setToolTipText("Item type");
        typeBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                typeBoxItemStateChanged(evt);
            }
        });

        consumableBox.setText("Consumable");
        consumableBox.setToolTipText("Item consumable (y/n)");
        consumableBox.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                consumableBoxStateChanged(evt);
            }
        });
        consumableBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                consumableBoxActionPerformed(evt);
            }
        });

        currencyValueBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));

        boundBox.setText("Bound");
        boundBox.setToolTipText("Item consumable (y/n)");
        boundBox.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                boundBoxStateChanged(evt);
            }
        });
        boundBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boundBoxActionPerformed(evt);
            }
        });

        typeModLabel.setText("Type Modifier: ");

        totalUsesBox.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("###0"))));
        totalUsesBox.setEnabled(false);

        totalUsesLabel.setText("Total Uses:");

        typeLabel.setText("Item Type:");

        jLabel9.setText("Item Unlocks:");

        unlocksCombo.setToolTipText("Doors item unlocks");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(itemListPane, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(typeBox, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(typeLabel))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(totalUsesLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(ticksRemainLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(currencyValueLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(typeModLabel, javax.swing.GroupLayout.Alignment.LEADING))
                                .addGap(10, 10, 10)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(totalUsesBox, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(typeModBox, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(ticksRemainBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(currencyValueBox, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(temporaryBox)
                                    .addComponent(lightSourceBox)
                                    .addComponent(visibleBox)
                                    .addComponent(consumableBox)
                                    .addComponent(boundBox)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(closeButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(addButton, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(idLabel)
                                    .addComponent(idBox, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(8, 8, 8)
                                        .addComponent(nameLabel))
                                    .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(nameBox))))
                            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane1))
                        .addGap(9, 9, 9))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(descriptionLabel)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(unlocksCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(idLabel)
                            .addComponent(nameLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nameBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(idBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(descriptionLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(typeLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(typeBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lightSourceBox)
                                .addGap(0, 0, 0)
                                .addComponent(visibleBox)
                                .addGap(0, 0, 0)
                                .addComponent(consumableBox)
                                .addGap(0, 0, 0)
                                .addComponent(temporaryBox)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(boundBox))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(typeModBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(typeModLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(totalUsesBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(totalUsesLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(ticksRemainBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(ticksRemainLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(currencyValueLabel)
                                    .addComponent(currencyValueBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(unlocksCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(71, 71, 71)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(addButton)
                            .addComponent(closeButton)))
                    .addComponent(itemListPane))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

	private void itemListTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_itemListTableMouseClicked
            int row = itemListTable.getSelectedRow();

            if (row > -1) {
                if (itemListTable.getModel().getValueAt(row, 0) != null) {
                    int id = Integer.parseInt(itemListTable.getModel().getValueAt(row, 0).toString());
                    getItemData(id);
                }
            }
	}//GEN-LAST:event_itemListTableMouseClicked

	private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
            dispose();
	}//GEN-LAST:event_closeButtonActionPerformed

	private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
            addItem();
	}//GEN-LAST:event_addButtonActionPerformed

    private void temporaryBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_temporaryBoxStateChanged

    }//GEN-LAST:event_temporaryBoxStateChanged

    private void temporaryBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_temporaryBoxActionPerformed
        if (temporaryBox.isSelected()) {
            ticksRemainBox.setEnabled(true);
            ticksRemainBox.setText("0");
        } else {
            ticksRemainBox.setEnabled(false);
            ticksRemainBox.setText("");
        }
    }//GEN-LAST:event_temporaryBoxActionPerformed

    private void visibleBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visibleBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_visibleBoxActionPerformed

    private void typeBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_typeBoxItemStateChanged

    }//GEN-LAST:event_typeBoxItemStateChanged

    private void consumableBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_consumableBoxStateChanged

    }//GEN-LAST:event_consumableBoxStateChanged

    private void consumableBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_consumableBoxActionPerformed
        if (consumableBox.isSelected()) {
            totalUsesBox.setEnabled(true);
            totalUsesBox.setText("0");
        } else {
            totalUsesBox.setEnabled(false);
            totalUsesBox.setText("");
        }
    }//GEN-LAST:event_consumableBoxActionPerformed

    private void boundBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_boundBoxStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_boundBoxStateChanged

    private void boundBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boundBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_boundBoxActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addButton;
    private javax.swing.JCheckBox boundBox;
    private javax.swing.JButton closeButton;
    private javax.swing.JCheckBox consumableBox;
    private javax.swing.JFormattedTextField currencyValueBox;
    private javax.swing.JLabel currencyValueLabel;
    private javax.swing.JTextPane descriptionBox;
    private javax.swing.JLabel descriptionLabel;
    private javax.swing.JFormattedTextField idBox;
    private javax.swing.JLabel idLabel;
    private javax.swing.JScrollPane itemListPane;
    private javax.swing.JTable itemListTable;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jList1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JCheckBox lightSourceBox;
    private javax.swing.JFormattedTextField nameBox;
    private javax.swing.JLabel nameLabel;
    private javax.swing.JCheckBox temporaryBox;
    private javax.swing.JFormattedTextField ticksRemainBox;
    private javax.swing.JLabel ticksRemainLabel;
    private javax.swing.JFormattedTextField totalUsesBox;
    private javax.swing.JLabel totalUsesLabel;
    private javax.swing.JComboBox typeBox;
    private javax.swing.JLabel typeLabel;
    private javax.swing.JFormattedTextField typeModBox;
    private javax.swing.JLabel typeModLabel;
    private javax.swing.JComboBox unlocksCombo;
    private javax.swing.JCheckBox visibleBox;
    // End of variables declaration//GEN-END:variables
}
